import 'package:flutter/material.dart';
import 'package:mall/constant/app_colors.dart';
import 'package:mall/constant/app_strings.dart';
import 'package:mall/modules/model/fill_in_order_entity.dart';
import 'package:mall/ui/page/goods/widgets/goods_price_widget.dart';
import 'package:mall/utils/image_component/image_component.dart';

class OrderGoodsListWidget extends StatelessWidget {
  const OrderGoodsListWidget({super.key, required this.checkedGoodsList});

  final List<FillInOrderCheckedgoodslist>? checkedGoodsList;

  @override
  Widget build(BuildContext context) {
    return ListView.separated(
      padding: EdgeInsets.zero,
      physics: NeverScrollableScrollPhysics(),
      shrinkWrap: true,
      itemCount: checkedGoodsList?.length ?? 0,
      itemBuilder: (context, index) {
        return _goodsItem(checkedGoodsList![index]);
      },
      separatorBuilder: (BuildContext context, int index) {
        return SizedBox(height: 10);
      },
    );
  }

  Widget _goodsItem(FillInOrderCheckedgoodslist checkedGoods) {
    return Container(
      color: AppColors.C_FFFFFF,
      height: 95,
      child: Row(
        children: <Widget>[
          //商品
          ImageComponent(
            checkedGoods.picUrl,
            size: 94,
            borderRadius: BorderRadius.circular(10),
          ),
          SizedBox(width: 10),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                //标题
                Text(
                  checkedGoods.goodsName ?? "",
                  style: TextStyle(
                    color: AppColors.C_333333,
                    fontSize: 13,
                  ),
                ),

                //规格
                Text(
                  checkedGoods.specifications?.join(',') ?? "",
                  style: TextStyle(
                    color: AppColors.C_B8B8B8,
                    fontSize: 13,
                  ),
                  maxLines: 2,
                  overflow: TextOverflow.ellipsis,
                ),
                //价格
                GoodsPriceWidget(
                  price: checkedGoods.price,
                  priceFontSize: 18,
                )
              ],
            ),
          ),
          SizedBox(width: 10),
          //数量
          Text("${AppStrings.GOODS_NUMBER}${checkedGoods.number}"),
        ],
      ),
    );
  }
}
